﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using HA.Data;
using HA.ModFlow.Controls.DisplayOptions;

namespace HA.ModFlow.Application
{
    /// <summary>
    /// winDisplayOption.xaml 的交互逻辑
    /// </summary>
    public partial class winDisplayOption : Window
    {
        public winDisplayOption(DisplayOption DisplayOption)
        {
            InitializeComponent();
            this.DisplayOptions = DisplayOption;
            this.DataContext = this.DisplayOptions;
        }

        private DisplayOption _DisplayOptions = new DisplayOption();

        public DisplayOption DisplayOptions
        {
            get { return _DisplayOptions; }
            set { _DisplayOptions = value; }
        }

        private void lvApp_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {


        }

        private void btnColor_Click(object sender, RoutedEventArgs e)
        {

            System.Windows.Forms.ColorDialog dlg = new System.Windows.Forms.ColorDialog();
            Color color = new Color();
            dlg.Color = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B);

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //this .RectColor.Fill = Color.FromArgb(dlg.Color.A, dlg.Color.R, dlg.Color.G, dlg.Color.B);

                SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromArgb(dlg.Color.A, dlg.Color.R, dlg.Color.G, dlg.Color.B));
                this.RectColor.Fill = solidColorBrush;
            }


            //System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog();
            ////dlg.Color = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B);
            //if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            //{
            //    //System.Drawing.SolidBrush sb = new System.Drawing.SolidBrush(color);
            //    //SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromArgb(sb.Color.A, sb.Color.R, sb.Color.G, sb.Color.B));
            //    //Application.Current.MainWindow.Background = solidColorBrush;
            //}

        }

        private void btnContourOption_Click(object sender, RoutedEventArgs e)
        {
            HA.ModFlow.Controls.DisplayOptions.winContourOption win = new Controls.DisplayOptions.winContourOption(this.DisplayOptions.Grid3d.ContourOption.ContourGeneral);
            win.ShowDialog();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
            this.Close();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //this.btnCross;
            //Canvas canvas = new Canvas();
            //canvas.Width = 14;
            //canvas.Height = 14;
            //Path path = new Path();
            //GeometryConverter gc = new GeometryConverter();
            //path.Data = (Geometry)gc.ConvertFromString("M0,0 L14,0");
            //path.Margin = new Thickness(0, 7, 0, 0);
            //path.Stroke = new SolidColorBrush(Colors.Black);
            //path.StrokeThickness = 2;
            //canvas.Children.Add(path);

            //path = new Path();
            //gc = new GeometryConverter();
            //path.Data = (Geometry)gc.ConvertFromString("M0,0 L0,14");
            //path.Margin = new Thickness(7, 0, 0, 0);
            //path.Stroke = new SolidColorBrush(Colors.Black);
            //path.StrokeThickness = 2;
            //canvas.Children.Add(path);
            //this.btnCross.Content = canvas;
            System.Drawing.Color color = this.DisplayOptions.Modflow.Wells.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            this.btnCross.Content = this.DisplayOptions.Modflow.GetStyle(14, clr,this.DisplayOptions.Modflow.Wells.DisplayShape);

            color = this.DisplayOptions.Modflow.Drains.Color;
            clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            this.btnCircularpoints.Content = this.DisplayOptions.Modflow.GetStyle(14, clr, this.DisplayOptions.Modflow.Drains.DisplayShape);

            color = this.DisplayOptions.Modflow.Rivers.Color;
            clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            this.btnTriangle.Content = this.DisplayOptions.Modflow.GetStyle(14, clr, this.DisplayOptions.Modflow.Rivers.DisplayShape);

            color = this.DisplayOptions.Modflow.GeneralHead.Color;
            clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            this.btnSquare.Content = this.DisplayOptions.Modflow.GetStyle(14, clr, this.DisplayOptions.Modflow.GeneralHead.DisplayShape);

            color = this.DisplayOptions.Modflow.ConstantHead.Color;
            clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            this.btnDiamond.Content = this.DisplayOptions.Modflow.GetStyle(14, clr, this.DisplayOptions.Modflow.ConstantHead.DisplayShape);

            color = this.DisplayOptions.Modflow.TransientData.Color;
            clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            this.btnTriangleNoFill.Content = this.DisplayOptions.Modflow.GetStyle(14, clr, this.DisplayOptions.Modflow.TransientData.DisplayShape);

            color = this.DisplayOptions.Modflow.HorizFlowBarrier.Color;
            clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            this.btnLine.Content = this.DisplayOptions.Modflow.GetStyle(2, clr, this.DisplayOptions.Modflow.HorizFlowBarrier.DisplayShape);

            color = this.DisplayOptions.Modflow.DryCell.Color;
            clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            this.btnDryCell.Content = this.DisplayOptions.Modflow.GetStyle(14, clr, this.DisplayOptions.Modflow.DryCell.DisplayShape);

            color = this.DisplayOptions.Modflow.WaterTable.Color;
            clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            this.btnWaterTable.Content = this.DisplayOptions.Modflow.GetStyle(2, clr, this.DisplayOptions.Modflow.WaterTable.DisplayShape);

            color = this.DisplayOptions.Modflow.MarkFloodedCell.Color;
            clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            this.btnMarkFloodedCell.Content = this.DisplayOptions.Modflow.GetStyle(14, clr, this.DisplayOptions.Modflow.MarkFloodedCell.DisplayShape);

        }

        private void btnCross_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.Modflow.Wells.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.Modflow.Wells.Size, this.DisplayOptions.Modflow.Wells.DisplayShape);
            if (win.ShowDialog().Value)
            {
                this.btnCross.Content = this._DisplayOptions.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                Color cl = win.Clr2;
                this.DisplayOptions.Modflow.Wells.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                this.DisplayOptions.Modflow.Wells.Size = win.Size;
                this.DisplayOptions.Modflow.Wells.DisplayShape = win.Displayshape;
            }
        }

        private void btnCircularpoints_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.Modflow.Drains.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.Modflow.Drains.Size, this.DisplayOptions.Modflow.Drains.DisplayShape);
            if (win.ShowDialog().Value)
            {
                this.btnCircularpoints.Content = this._DisplayOptions.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                Color cl = win.Clr2;
                this.DisplayOptions.Modflow.Drains.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                this.DisplayOptions.Modflow.Drains.Size = win.Size;
                this.DisplayOptions.Modflow.Drains.DisplayShape = win.Displayshape;
            }
        }

        private void btnTriangle_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.Modflow.Rivers.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.Modflow.Rivers.Size, this.DisplayOptions.Modflow.Rivers.DisplayShape);
            if (win.ShowDialog().Value)
            {
                this.btnTriangle.Content = this._DisplayOptions.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                Color cl = win.Clr2;
                this.DisplayOptions.Modflow.Rivers.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                this.DisplayOptions.Modflow.Rivers.Size = win.Size;
                this.DisplayOptions.Modflow.Rivers.DisplayShape = win.Displayshape;
            }
        }

        private void btnSquare_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.Modflow.GeneralHead.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.Modflow.GeneralHead.Size, this.DisplayOptions.Modflow.GeneralHead.DisplayShape);
            if (win.ShowDialog().Value)
            {
                this.btnSquare.Content = this._DisplayOptions.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                Color cl = win.Clr2;
                this.DisplayOptions.Modflow.GeneralHead.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                this.DisplayOptions.Modflow.GeneralHead.Size = win.Size;
                this.DisplayOptions.Modflow.GeneralHead.DisplayShape = win.Displayshape;
            }
        }

        private void btnDiamond_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.Modflow.ConstantHead.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.Modflow.ConstantHead.Size, this.DisplayOptions.Modflow.ConstantHead.DisplayShape);
            if (win.ShowDialog().Value)
            {
                this.btnDiamond.Content = this._DisplayOptions.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                Color cl = win.Clr2;
                this.DisplayOptions.Modflow.ConstantHead.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                this.DisplayOptions.Modflow.ConstantHead.Size = win.Size;
                this.DisplayOptions.Modflow.ConstantHead.DisplayShape = win.Displayshape;
            }
        }

        private void btnTriangleNoFill_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.Modflow.TransientData.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.Modflow.TransientData.Size, this.DisplayOptions.Modflow.TransientData.DisplayShape);
            if (win.ShowDialog().Value)
            {
                this.btnTriangleNoFill.Content = this._DisplayOptions.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                Color cl = win.Clr2;
                this.DisplayOptions.Modflow.TransientData.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                this.DisplayOptions.Modflow.TransientData.Size = win.Size;
                this.DisplayOptions.Modflow.TransientData.DisplayShape = win.Displayshape;
            }
        }

        private void btnLine_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.Modflow.HorizFlowBarrier.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winLineProperty win = new winLineProperty(clr, this.DisplayOptions.Modflow.HorizFlowBarrier.Size, this.DisplayOptions.Modflow.HorizFlowBarrier.DisplayShape);
            if (win.ShowDialog().Value)
            {
                this.btnLine.Content = this._DisplayOptions.Modflow.GetStyle(2, win.Clr, win.Displayshape);
                Color cl = win.Clr;
                this.DisplayOptions.Modflow.HorizFlowBarrier.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                this.DisplayOptions.Modflow.HorizFlowBarrier.Size = win.Size;
                this.DisplayOptions.Modflow.HorizFlowBarrier.DisplayShape = win.Displayshape;
            }
        }     

        private void btnDryCell_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.Modflow.DryCell.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.Modflow.DryCell.Size, this.DisplayOptions.Modflow.DryCell.DisplayShape);
            if (win.ShowDialog().Value)
            {
                this.btnDryCell.Content = this._DisplayOptions.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                Color cl = win.Clr2;
                this.DisplayOptions.Modflow.DryCell.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                this.DisplayOptions.Modflow.DryCell.Size = win.Size;
                this.DisplayOptions.Modflow.DryCell.DisplayShape = win.Displayshape;
            }
        }

        private void btnWaterTable_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.Modflow.WaterTable.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winLineProperty win = new winLineProperty(clr, this.DisplayOptions.Modflow.WaterTable.Size, this.DisplayOptions.Modflow.WaterTable.DisplayShape);
            if (win.ShowDialog().Value)
            {
                this.btnWaterTable.Content = this._DisplayOptions.Modflow.GetStyle(2, win.Clr, win.Displayshape);
                Color cl = win.Clr;
                this.DisplayOptions.Modflow.WaterTable.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                this.DisplayOptions.Modflow.WaterTable.Size = win.Size;
                this.DisplayOptions.Modflow.WaterTable.DisplayShape = win.Displayshape;
            }
        }

        private void btnMarkFloodedCell_Click(object sender, RoutedEventArgs e)
        {
            System.Drawing.Color color = this.DisplayOptions.Modflow.MarkFloodedCell.Color;
            Color clr = Color.FromArgb(color.A, color.R, color.G, color.B);
            winSysbolAttributes win = new winSysbolAttributes(clr, this.DisplayOptions.Modflow.MarkFloodedCell.Size, this.DisplayOptions.Modflow.MarkFloodedCell.DisplayShape);
            if (win.ShowDialog().Value)
            {
                this.btnMarkFloodedCell.Content = this._DisplayOptions.Modflow.GetStyle(14, win.Clr2, win.Displayshape);
                Color cl = win.Clr2;
                this.DisplayOptions.Modflow.MarkFloodedCell.Color = System.Drawing.Color.FromArgb(cl.A, cl.R, cl.G, cl.B);
                this.DisplayOptions.Modflow.MarkFloodedCell.Size = win.Size;
                this.DisplayOptions.Modflow.MarkFloodedCell.DisplayShape = win.Displayshape;
            }
        }


    }
}
